<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${news.id}"
                               type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类别：</label>
                            <div class="col-sm-3">

                                <select data-placeholder="--选择--" id="catId"
                                        name="catId"
                                        class="form-control chosen-select" tabindex="2"

                                        th:value="${news.catId}">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8">
                                <input type="hidden" id="catName" name="catName" th:value="${news.catName}"/>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">来源：</label>
                            <div class="col-sm-3">
                                <input id="sourceName" name="sourceName"
                                       th:value="${news.sourceName}"
                                       class="form-control"
                                       type="text" maxlength="10">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="col-sm-8">
                                <input id="title" name="title"
                                       th:value="${news.title}"
                                       class="form-control"
                                       type="text" maxlength="30">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">内容：</label>
                            <div class="col-sm-8">
                                <input type="hidden" id="content" name="content" th:value="${news.content}"/>
                                <div id="contentEditorcontent">

                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
<script type="text/javascript" src="/js/appjs/novel/news/edit.js">
</script>
<script>
    $.ajax({
        type: "GET",
        url: "/novel/category/list",
        data: {limit:100,offset:0},
        success: function (r) {
            if (r.code == 0) {
                var list = r.data.rows;
                var catHtml = "<option>请选择</option>";
                for(var i = 0 ; i < list.length ; i++){
                    var cat = list[i];
                    if(cat.id == $("#catId").attr("value")){
                        catHtml += ("<option selected value='"+cat.id+"'>"+cat.name+"</option>");
                    }else{
                        catHtml += ("<option value='"+cat.id+"'>"+cat.name+"</option>");
                    }

                }
                $("#catId").html(catHtml);
                $("#catId").change(function(){
                    var catName = $(this).find("option:selected").text();
                    if(catName != '请选择'){

                        $("#catName").val(catName);
                    }else{
                        $("#catName").val('');
                    }
                });
            } else {
                layer.msg(r.msg);
            }
        },
    });
</script>
</body>
</html>
